{% extends "devhub/base.html" %}

{% from "devhub/includes/macros.html" import tip %}

{% set title = _('Manage Authors & License') %}

{% block title %}
{{ dev_page_title(title, addon) }}
{% endblock %}

{% block content %}
<header>
  {{ l10n_menu(addon.default_locale) }}
  <h2>{{ addon.name }}</h2>
</header>
<section id="edit-addon" class="primary devhub-form" role="main">
<form method="post" class="item">
  {% csrf_token %}
  <div class="item_wrapper">
    <table>
      <tr>
        <th>
          {{ _('Authors') }}
          <a id="what-are-roles" href="#">{{ _('About author roles') }}</a>
        </th>
        <td>
          {{ user_form.management_form }}
          {{ user_form.non_form_errors() }}
          <ul id="authors_confirmed" class="author_list">
          {% for form in user_form.forms %}
            <li class="author {{ 'initial' if not form.user.errors else '' }}">
              <span class="handle">&nbsp;</span>
              {{ form.user.errors }}
              {{ form.user }}
              {{ form.role }}
              {{ form.listed }}{{ form.listed.label_tag(label_suffix='') }}
              {{ form.id }}
              <span class="js-hidden delete">{{ form.DELETE }}{{ form.DELETE.label_tag() }}</span>
              <span class="js-hidden position">{{ form.position }}</span>
              <a href="#" class="remove">x</a>
            </li>
          {% endfor %}
          </ul>
        </td>
      </tr>
      <tr>
        <th {% if not authors_pending_confirmation_form.forms %}class="invisible"{% endif %}>
          {{ tip(_('Authors pending confirmation'),
             _("Authors that have been added to this add-on but haven't confirmed.")) }}
        </th>
        <td>
          {{ authors_pending_confirmation_form.management_form }}
          {{ authors_pending_confirmation_form.non_form_errors() }}
          <ul id="authors_pending_confirmation" class="author_list">
          {% for form in authors_pending_confirmation_form.forms %}
            <li class="author {{ 'initial' if not form.user.errors else '' }}">
              {# No handle, we don't allow re-organizing authors pending confirmation as it doesn't make sense #}
              {{ form.user.errors }}
              {{ form.user }}
              {{ form.role }}
              {{ form.listed }}{{ form.listed.label_tag(label_suffix='') }}
              {{ form.id }}
              <span class="js-hidden delete">{{ form.DELETE }}{{ form.DELETE.label_tag() }}</span>
              <a href="#" class="remove">x</a>
            </li>
          {% endfor %}
          </ul>
        </td>
      </tr>
      {% if license_form %}
        {% include "devhub/includes/license_form.html" %}
      {% endif %}
      {% if policy_form %}
        {% include "devhub/includes/policy_form.html" %}
      {% endif %}
    </table>
  </div>
  <div class="listing-footer"><button type="submit">{{ _('Save Changes') }}</button></div>
</form>
{% with form=authors_pending_confirmation_form.empty_form %}
<ul id="user-form-template" class="hidden">
  <li class="blank">
    {{ form.user }}
    {{ form.role }}
    {{ form.listed }}{{ form.listed.label_tag(label_suffix='') }}
    <span class="js-hidden">{{ form.DELETE }}{{ form.DELETE.label_tag() }}</span>
    <a href="#" class="remove">x</a>
  </li>
</ul>
{% endwith %}
</section>
{% include "devhub/includes/addons_edit_nav.html" %}

<div id="author-roles-help" class="popup">
  {% trans %}
  <p>Add-ons can have any number of authors with 2 possible roles:</p>
  <ul>
    <li><b>Owner:</b> Can manage all aspects of the add-on's listing, including adding and removing other authors</li>
    <li><b>Developer:</b> Can manage all aspects of the add-on's listing, except for adding and removing other authors</li>
  </ul>
  {% endtrans %}
  <p><a href="#" class="cancel close">{{ _('Close') }}</a></p>
</div>
{% endblock %}
